﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace EasyMapping.Core.Tests
{
    /// <summary>
    /// Summary description for UnitTest1
    /// </summary>
    [TestClass]
    public class UnitTest_Core
    {
        public UnitTest_Core()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        

        [TestMethod]
        public void TestMethod_Get()
        {
            Member m = PersistenceManager.GetObject<Member>("GetMemberByEmail",
                                     new ParameterProperty[] {new ParameterProperty() { Name = "@email", Value = "EasyMapping@gmail.com" }} )    ;
            int i = 0;
        }

        [TestMethod]
        public void TestMethod_Get1()
        {
            Member m = PersistenceManager.GetObject<Member>("GetMemberByLoginName",
                                     new ParameterProperty[] { new ParameterProperty() { Name = "@loginName", Value = "EasyMapping" } });
            int i = 0;
        }

        [TestMethod]
        public void TestMethod_GetList()
        {
            List<Member> list = PersistenceManager.GetList<Member>("GetMembersByFirstName",
                new ParameterProperty[] { new ParameterProperty() { Name = "@firstName", Value = "Easy" } });
            int i = 0;            
        }

        [TestMethod]
        public void TestMethod_Save()
        {
            Member m = new Member() { Email = "pie.li11@gmail.com", FirstName = "pie", LastName = "li", LoginName = "pie.li11", Password = "" };
            bool flag = PersistenceManager.SaveObject<Member>("SaveMember", m);
            int i = 0;
        }

        [TestMethod]
        public void TestMethod_Update()
        {
            Member m = new Member() { Email = "pie.li16@gmail.com", FirstName = "pie", LastName = "li", LoginName = "pie.li16", Password = "" };
            bool flag = PersistenceManager.SaveObject<Member>("SaveMember", m);
            m.Password = "001";
            bool isUpdate = PersistenceManager.UpdateObject<Member>("UpdateMember", m);
            int i = 0;
        }

        [TestMethod]
        public void TestMethod_Delete()
        {
            Member m = new Member() { Email = "pie.li22@gmail.com", FirstName = "pie2", LastName = "li2", LoginName = "pie.li22", Password = "" };
            bool flag = PersistenceManager.SaveObject<Member>("SaveMember", m);
            bool isDelete = PersistenceManager.SaveObject<Member>("DeleteMember", m);
            int i = 0;        
        }
    }
}
